<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录。</title>
  <style>

  </style>
</head>

<body>
  <form action="">
    用户名:<input type="text" id="Username"> <br>
    密码:<input type="password" id="password"> <br>
    <button onclick="aa()" id="login" type="button">登录</button>
  </form>
</body>
<script>
  function aa() {
    let ina = document.getElementsByTagName('button')
    let name = document.getElementById('Username')
    let pass = document.getElementById('password')
    if (name.value.length > 5 && name.value.match(/^[\u4E00-\u9FA5A-Za-z0-9]+$/)) {
      name.style.border = '1px solid blue'
    } else {
      name.style.border = '1px solid red'
    } if (pass.value.length > 8 && pass.value.match(/[A-Z-a-z-0-9][!@#$%^&*?]+$/)) {
      pass.style.border = '1px solid blue'
    } else {
      pass.style.border = '1px solid red'
    }
  }
</script>

</html>